package com.rock.code.bigdata.bigdatainterface.service;

import com.rock.code.bigdata.bigdatainterface.domain.Constants;
import com.rock.code.bigdata.bigdatainterface.util.MyUtil;
import com.rock.code.hdfs.HdfsAPP;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import java.io.DataInputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import static com.rock.code.bigdata.bigdatainterface.util.MyUtil.timeToTimeStamp;

/**
 * 历史数据采集定时任务
 */
public class HisDataCollTask implements Job {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");


    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        HistoryDataService historyDataService = (HistoryDataService) jobExecutionContext.getMergedJobDataMap().get("historyDataService");
        String area_ip = (String) jobExecutionContext.getMergedJobDataMap().get("area_ip");
        Date today = new Date();
        String date = sdf.format(today);
        String day = date.split(" ")[0] + " " + "00:00:00";
        String taskEnd = timeToTimeStamp(day);
        String taskStart = Long.parseLong(taskEnd) - (24 * 60 * 60 * 1000) + "";
        historyDataService.getYesData(area_ip, taskStart, taskEnd, "0");
    }


}
